home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / diskmags / 0022-3.564 / dmg-3419 / pack_snt.205 / prg_depa.s < prev    next >
Text File  |  1991-04-25  |  3KB  |  175 lines

  1. * Hallo, Arnoud. Dit is de source om een Sentry packed Prg te unpacken.
  2.  
  3.     lea    packed(pc),a0    ; source adres
  4.     lea    buf(pc),a1    ; dest. adres
  5.     bsr    depack_exe    ; depack PRG
  6.  
  7. depack_exe
  8.     move.l    2(a0),d0        ; length of text
  9.     add.l    #28,d0            ; +tos header=file length
  10.     cmp.l    #"2.02",516(a0)        ; test for v2.02 executable
  11.     bne.s    205$
  12.     cmp.l    #" by ",520(a0)
  13.     bne.s    205$
  14.     cmp.l    #"Eagl",524(a0)
  15.     bne.s    205$
  16.     lea    530(a0),a3
  17.     move.l    #530,d2
  18.     move.l    252(a0),d1
  19.     bra    exe_depack
  20. 205$    cmp.l    #"2.05",522(a0)        ; test for v2.05 executable
  21.     bne.s    2$
  22.     cmp.l    #" by ",526(a0)
  23.     bne.s    2$
  24.     cmp.l    #"Eagl",530(a0)
  25.     bne.s    2$
  26.     lea    536(a0),a3
  27.     move.l    #536,d2
  28.     move.l    258(a0),d1
  29.     bra    exe_depack
  30. 2$    rts                ; Not packed!
  31. exe_depack
  32.     clr.w    _sam
  33.     cmp.l    #$4e714e71,106(a0)    ; modules?
  34.     beq.s    .nomod
  35.     move.w    #1,_sam
  36.     add.l    #34,d2            ; jip
  37.     add.l    #34,a3
  38. .nomod    sub.l    d2,d0
  39.     lea    (a3,d0.l),a0    ; source adres
  40.     lea    (a1,d1.l),a2
  41.     move.l    d1,-(sp)    ; depacked length
  42.     move.l    a3,-(sp)
  43.     move.l    a1,a3
  44.     bsr    exec_unp
  45.     move.l    (sp)+,a1
  46.     subq.l    #8,a1
  47.     tst    _sam
  48.     beq.s    .exit
  49.     bsr    ENDUNP        ; samples
  50. .exit    move.l    (sp)+,d0    ; d0=depacked length
  51.     rts
  52. _sam    dc.w    0
  53. exec_unp
  54.     bsr    get_long
  55. unp_loop
  56.     bsr.s    .getbit
  57. .cont    bcs.s   .blocks
  58.     bsr.s    .getbit
  59.     bcs.s    .copy_2
  60.     move.b    -(a0),-(a2)    ; 1 byte copy
  61.     bra    l_col
  62. .copy_2    bsr.s    .getbit
  63.     bcs.s    .c_more
  64.     moveq    #1,d2        ; copy 2 bytes
  65.     bra.s    .copy
  66. .c_more    lea    copy_tab(pc),a4
  67. .c_loop    move.l    (a4)+,d1
  68.     bsr.s    .getbyte        ; haal aantal
  69.     subq.w    #1,d2
  70.     bpl.s    .found
  71.     bra.s    .c_loop
  72. .found    swap    d1
  73.     add.w    d1,d2
  74.  
  75. .copy    move.b    -(a0),-(a2)
  76.     dbf    d2,.copy
  77.     bra    l_col
  78.  
  79. .get_off
  80.     MOVEQ    #1,D1        ;OFFSET
  81.     BSR.S    .getbyte
  82.     move.b    (a4,d2),d1    ; bits
  83.     ADD.W    D2,D2
  84.     ext.w    d1
  85.     move.w    4(a4,d2),d4
  86.     bsr.s    .getbyte
  87.     add.w    d4,d2
  88.     rts
  89. .getbit    add.l    d0,d0    ;LSR.L    #1,D0
  90.     beq.s    .haha
  91.     rts
  92. .haha    bsr.s    get_long
  93.     addx.l    d0,d0    ;ROXR.L  #1,D0
  94.     rts
  95. .haha1    bsr.s    get_long
  96.     addx.l    d0,d0    ;ROXR.L  #1,D0
  97.     bra.s    .getbyt
  98. .getbyte
  99.     CLR.W   D2
  100. .loop    add.l    d0,d0    ;LSR.L    #1,D0
  101.     beq.s    .haha1
  102. .getbyt    addx.L  d2,D2 
  103.     DBF     D1,.loop
  104.     RTS
  105.  
  106. .blocks    bsr.s    .getbit
  107.     bcs.s    .string3
  108.     moveq    #1,d3        ; 2 bytes-string
  109.     moveq    #8-1,d1    ; small-bits-offset
  110.     bsr.s    .getbyte
  111.     bra.s    .s_copy
  112. .string3
  113.     lea    small_offset(pc),a4
  114.     bsr.s    .getbit
  115.     bcs.s    .string_more
  116.     moveq    #2,d3        ; 3 bytes-string
  117.     bra.s    .do_strings
  118. .string_more
  119.     moveq    #1,d1        ; 2 bits-commando
  120.     bsr.s    .getbyte
  121.     subq.w    #1,d2        ; large string?
  122.     bmi.s    .large
  123.     moveq    #3,d3        ; minimaal 4 bytes-string
  124.     add.w    d2,d3        ; meer?
  125.     bra.s    .do_strings
  126. .large    lea    aantal_tab(pc),a4
  127.     bsr.s    .get_off
  128.     move.w    d2,d3
  129.     lea    offset_tab(pc),a4
  130. .do_strings
  131.     bsr.s    .get_off
  132. .s_copy    move.b    -1(a2,d2.w),-(a2) 
  133.     dbf    d3,.s_copy
  134.  
  135. l_col    cmpa.l    a2,a3 
  136.     blt    unp_loop
  137. ex_unp    RTS
  138. get_long
  139.     moveq    #3,d6
  140. .get    lsl.l    #8,d0
  141.     move.b    -(a0),d0
  142.     dbf    d6,.get
  143.     move.w    #$10,ccr
  144.     rts
  145. offset_tab
  146.     dc.b    5-1,8-1,9-1,13-1
  147.     dc.w    1,1+32,1+32+256,1+32+256+512
  148. aantal_tab
  149.     dc.b    2-1,3-1,5-1,9-1
  150.     dc.w    6,6+4,6+4+8,6+4+8+32
  151. small_offset
  152.     dc.b    4-1,5-1,7-1,9-1
  153.     dc.w    1,1+16,1+16+32,1+16+32+128
  154. copy_tab
  155.     dc.w    2,1
  156.     dc.w    5,2
  157.     dc.w    12,3
  158.     dc.w    27,4
  159.     even
  160. ENDUNP
  161.     move.l    a3,a0
  162.     add.l    (a1)+,a0
  163.     move.l    (a1),d0
  164.     lea    (a0,d0.l),a2
  165. .loop    move.b    (a0)+,d0
  166.     sub.b    d0,(a0)
  167.     neg.b    (a0)    
  168.     cmp.l    a2,a0
  169.     blt.s    .loop
  170.     rts
  171.  
  172. packed    incbin    snt205.prg
  173.  
  174. buf    ds.l    10000
  175.